// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const math = require("remark-math");
const katex = require("rehype-katex");

async function createConfig() {
  const mdxMermaid = await import("mdx-mermaid");

  /** @type {import('@docusaurus/types').Config} */
  return {
    title: "Основы программирования",
    tagline: "Азы программирования на языках C и C++",
    favicon: "img/favicon.ico",

    // Set the production url of your site here
    url: "https://cpp1.wiki.iu5edu.ru/",
    // Set the /<baseUrl>/ pathname under which your site is served
    // For GitHub pages deployment, it is often '/<projectName>/'
    baseUrl: "/",

    // GitHub pages deployment config.
    // If you aren't using GitHub pages, you don't need these.
    organizationName: "ИУ5 курсы", // Usually your GitHub org/user name.
    projectName: "cpp1", // Usually your repo name.

    onBrokenLinks: "throw",
    onBrokenMarkdownLinks: "warn",

    // Even if you don't use internalization, you can use this field to set useful
    // metadata like html lang. For example, if your site is Chinese, you may want
    // to replace "en" with "zh-Hans".
    i18n: {
      defaultLocale: "ru",
      locales: ["ru"],
    },

    presets: [
      [
        "classic",
        /** @type {import('@docusaurus/preset-classic').Options} */
        ({
          docs: {
            remarkPlugins: [mdxMermaid.default, math],
            rehypePlugins: [katex],
            sidebarPath: require.resolve("./sidebars.js"),
            // Please change this to your repo.
            // Remove this to remove the "edit this page" links.
            editUrl:
              "https://hub.mos.ru/iu5bmstu/lections-and-labs/cpp1/textbook/-/tree/main/website",
          },
          blog: {
            showReadingTime: true,
            // Please change this to your repo.
            // Remove this to remove the "edit this page" links.
            editUrl:
              "https://hub.mos.ru/iu5bmstu/lections-and-labs/cpp1/textbook/-/tree/main/website",
          },
          theme: {
            customCss: require.resolve("./src/css/custom.css"),
          },
          sitemap: {
            changefreq: "weekly",
            priority: 0.5,
            ignorePatterns: ["/tags/**"],
            filename: "sitemap.xml",
          },
        }),
      ],
    ],

    themeConfig:
      /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
      ({
        // Replace with your project's social card
        image: "img/social-card.jpg",
        navbar: {
          title: "Основы программирования",
          logo: {
            alt: "Основы программирования Logo",
            src: "img/logo.svg",
          },
          items: [
            {
              type: "doc",
              docId: "intro",
              position: "left",
              label: "Руководство",
            },
            { to: "/blog", label: "Блог", position: "left" },
            {
              href: "/documents/cpp1-textbook.docx",
              label: "docx",
              position: "right",
            },
            {
              href: "https://hub.mos.ru/iu5bmstu/lections-and-labs/cpp1/",
              label: "МосХаб",
              position: "right",
            },
          ],
        },
        footer: {
          style: "dark",
          links: [
            {
              title: "Полезные ссылки",
              items: [
                {
                  label: "Руководство",
                  to: "/docs/intro",
                },
                {
                  label: "ИУ5 курсы",
                  to: "https://iu5edu.ru/",
                },
              ],
            },
            {
              title: "Сообщество",
              items: [
                {
                  label: "ИУ5 курсы в ВК",
                  href: "https://vk.com/iu5edu",
                },
                {
                  label: "ИУ5 в ВК",
                  href: "https://vk.com/iu5_official",
                },
                {
                  label: "ИУ5 в телеграме",
                  href: "https://t.me/iu5_bmstu",
                },
              ],
            },
            {
              title: "О руководстве",
              items: [
                {
                  label: "Условия",
                  href: "/legal/terms",
                  target: "_blank",
                },
                {
                  label: "Cookies",
                  to: "/legal/cookies-policy",
                  target: "_blank",
                },
              ],
            },
          ],
          copyright: `&copy; ИУ5 курсы. ${new Date().getFullYear()}.<br>Текст доступен по лицензии <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.ru"> Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</a>, если не указано иного.`,
        },
        prism: {
          theme: lightCodeTheme,
          darkTheme: darkCodeTheme,
        },
        metadata: [{ name: "keywords", content: "Программирование, C, C++" }],
      }),
    stylesheets: [
      {
        href: "https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css",
        type: "text/css",
        integrity:
          "sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM",
        crossorigin: "anonymous",
      },
    ],
    plugins: [
      [
        "@docusaurus/plugin-content-docs",
        {
          id: "legal",
          path: "legal",
          routeBasePath: "legal",
          breadcrumbs: true,
          editUrl:
            "https://hub.mos.ru/iu5bmstu/lections-and-labs/cpp1/textbook/-/tree/main/website",
        },
      ],
      [
        "./src/plugins/cookieconsent-plugin",
        {
          counterID: 94922463,
          websitePrivacyPolicyURL:
            "https://cpp1.wiki.iu5edu.ru/legal/cookies-policy",
        },
      ],
    ],
  };
}
module.exports = createConfig();
